﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 整除
{
    class Program
    {
        static void Main(string[] args)
        {
            Function1(1,6000);
            Console.WriteLine();
            Console.WriteLine(Function2());
            Console.WriteLine();
            Console.WriteLine(Function3(1,6000));
      

            Console.ReadKey();
        }
        static void Function1(int a,int b )
        {
            int temp = 0;
            for (int i = a; i < b+1; i++)
            {
                if (i % 5 == 3 && i % 7 == 2 && i % 3 == 2)
                {

                    for (int j = 0; j < (5 - (i.ToString().Length)); j++)
                    {
                        Console.Write(" ");
                    }
                    Console.Write(i);
                    temp++;
                    if (temp % 10 == 0)
                    {
                        Console.WriteLine("");
                    }
                }
            }
        }
        static string Function2()
        {
            string temp = "";
            int number = 0;

            for (int i = 1; i < 6001; i++)
            {
                if (i % 5 == 3 && i % 7 == 2 && i % 3 == 2)
                {
                    temp += i.ToString();
                    for (int j = 0; j < (5 - (i.ToString().Length)); j++)
                    {
                        temp += " ";//+表示字符串合并
                    }

                    number++;
                    if (number % 5 == 0)
                    {
                        temp += "\r\n";
                    }
                }
            }
            return temp;
        }
        /// <summary>
        /// 取范围a~b之间满足条件的数
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        static string Function3(int a, int b)
        {
            string temp = "";
            int number = 0;
            for (int i = a ; i <= b ; i++)
            {
                if (i % 5 == 3 && i % 7 == 2 && i % 3 == 2)
                {

                    for (int j = 0; j < ((b.ToString().Length) - (i.ToString().Length)); j++)
                    {
                        temp += " ";//+表示字符串合并
                    }
                    temp += i.ToString() + " ";
                    number++;
                    if (number % 5 == 0)
                    {
                        temp += "\r\n";
                    }
                }
            }
            return temp;
        }

    }
}
